const express = require('express');
const app = express();
app.listen(4000,()=>{
  console.log('服务器已启动!!');
});

let dataArr = {list:[
  {goods_name:"阳光美包新款单肩包女包时尚子母包四件套女", goods_price:"116.00", goods_pic:"uploads/like_01.png"},
  {goods_name:"爱仕达 30CM炒锅不粘锅NWG8330E电磁炉炒", goods_price:"1161.00", goods_pic:"uploads/like_02.png"},
  {goods_name:"捷波朗蓝牙耳机", goods_price:"116.00", goods_pic:"uploads/like_03.png"},
  {goods_name:"大方块，不知道是干什么用的", goods_price:"2116.00", goods_pic:"uploads/like_04.png"},
  {goods_name:"三星（G5500）", goods_price:"1816.00", goods_pic:"uploads/like_05.png"},
  {goods_name:"好像是个洗手液", goods_price:"3116.00", goods_pic:"uploads/like_06.png"}
]};
const path = require('path');
const template = require('express-art-template')
app.engine('html',template);
//统一加载静态资源
app.use('/fonts',express.static(path.join(__dirname,'./view/fonts')));
app.use('/images',express.static(path.join(__dirname,'./view/images')));
app.use('/styles',express.static(path.join(__dirname,'./view/styles')));
app.use('/uploads',express.static(path.join(__dirname,'./view/uploads')));

app.get('/cart',(req,res)=>{
  console.log(req);
  res.sendFile(path.join(__dirname,'./view/cart.html'));
});
app.get('/index',(req,res)=>{
  // res.sendFile(path.join(__dirname,'./view/index.html'),(err)=>{
  //   if(err){
  //     console.log(err);
  //     return res.send('404 not found');
  //   };
  // });
  res.render(path.join(__dirname,'./view/index.html'),dataArr)
});
app.get('/item',(req,res)=>{
  res.sendFile(path.join(__dirname,'./view/item.html'));
});
app.get('/list',(req,res)=>{
  res.sendFile(path.join(__dirname,'./view/list.html'));
});
app.get('/login',(req,res)=>{
  res.sendFile(path.join(__dirname,'./view/login.html'));
});
app.get('/register',(req,res)=>{
  res.sendFile(path.join(__dirname,'./view/register.html'));
});